﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using XiaoGang.Soft.XGWMS.COM;

namespace XiaoGang.Soft.XGWMS.DAL_SQL
{
    public class DAL_M013_STORAGE_OUTPUT
    {
        /// <summary>
        /// <p><b>方法名称</b>GetSingleData</p>	
        /// <p><b>概要説明  :</b>取得单条库存信息</p>
        /// <p><b>作成者    :</b>万岗</p>	
        /// <p><b>作成日    :</b>2008/09/09</p>	
        /// <p><b>修改历史  :</b></p>	
        /// </summary>
        /// <param type="class" name="model">检索条件</param>
        /// <returns type = "ReturnValue">检索结果表</returns>
        public ReturnValue GetSingleData(MODEL.MOD_M009_STORAGE_INPUT model)
        {
            SqlParameter parameter = new SqlParameter("@STORAGE_ID", SqlDbType.Char, 12);
            parameter.Value = model.STORAGE_ID.Trim();
            return XGWMS.DBUtility.SqlHelper.Query(DAL_SQL.DAL_M013_STORAGE_OUTPUT_SQL.Get_Single_Data_SQL, parameter);
        }

        /// <summary>
        /// <p><b>方法名称</b>GetSingleGoods</p>	
        /// <p><b>概要説明  :</b>取得特定仓库的特定商品信息</p>
        /// <p><b>作成者    :</b>万岗</p>	
        /// <p><b>作成日    :</b>2008/09/09</p>	
        /// <p><b>修改历史  :</b></p>	
        /// </summary>
        /// <param type="class" name="model">检索条件</param>
        /// <returns type = "ReturnValue">检索结果表</returns>
        public ReturnValue GetSingleGoods(MODEL.MOD_M009_STORAGE_INPUT model)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@GOODS_ID", SqlDbType.Char,12),
					new SqlParameter("@STOREROOM_ID", SqlDbType.Char,12)};
            parameters[0].Value = model.GOODS_ID;
            parameters[1].Value = model.STOREROOM_ID;
            return XGWMS.DBUtility.SqlHelper.Query(DAL_SQL.DAL_M013_STORAGE_OUTPUT_SQL.Get_Single_Goods_SQL, parameters);
        }

        /// <summary>
        /// <p><b>方法名称</b>GetSingleGoods</p>	
        /// <p><b>概要説明  :</b>特定仓库的特定商品数量的更新</p>
        /// <p><b>作成者    :</b>万岗</p>	
        /// <p><b>作成日    :</b>2008/09/09</p>	
        /// <p><b>修改历史  :</b></p>	
        /// </summary>
        /// <param type="class" name="model">更新信息</param>
        /// <returns type = "ReturnValue">执行结果信息</returns>
        public ReturnValue SubGoodsCount(MODEL.MOD_M009_STORAGE_INPUT model)
        {
            SqlParameter[] parameters = {					
					new SqlParameter("@TRANS_STATE", SqlDbType.Char,1),					
					new SqlParameter("@GOODS_ID", SqlDbType.Char,12),					
					new SqlParameter("@UNITS", SqlDbType.Int,4)};
            parameters[0].Value = model.TRANS_STATE;
            parameters[1].Value = model.GOODS_ID;
            parameters[2].Value = model.UNITS;

            return XGWMS.DBUtility.SqlHelper.ExecuteSql(DAL_M013_STORAGE_OUTPUT_SQL.Sub_Goods_Count_SQL, parameters);
        }

        /// <summary>
        /// <p><b>方法名称</b>InsertProcess</p>	
        /// <p><b>概要説明  :</b>货单的插入</p>
        /// <p><b>作成者    :</b>万岗</p>	
        /// <p><b>作成日    :</b>2008/09/09</p>	
        /// <p><b>修改历史  :</b></p>	
        /// </summary>
        /// <param type="class" name="model">货单信息</param>
        /// <returns type = "ReturnValue">执行结果信息</returns>
        public ReturnValue InsertProcess(MODEL.MOD_M009_STORAGE_INPUT model)
        {            
            SqlParameter[] parameters = {			
					new SqlParameter("@TRANS_STATE", SqlDbType.Char,1),
					new SqlParameter("@UPDATER_ID", SqlDbType.VarChar,12),
					new SqlParameter("@TERMINAL_CD", SqlDbType.VarChar,256),
					new SqlParameter("@STORAGE_ID", SqlDbType.Char,12),
					new SqlParameter("@STOREROOM_ID", SqlDbType.Char,12),
					new SqlParameter("@GOODS_ID", SqlDbType.Char,12),
					new SqlParameter("@UNITS", SqlDbType.Int,4),
					new SqlParameter("@MEMO", SqlDbType.VarChar,256)};
            parameters[0].Value = model.TRANS_STATE;
            parameters[1].Value = model.UPDATER_ID;
            parameters[2].Value = model.TERMINAL_CD;
            parameters[3].Value = model.STORAGE_ID;
            parameters[4].Value = model.STOREROOM_ID;
            parameters[5].Value = model.GOODS_ID;
            parameters[6].Value = model.UNITS;
            parameters[7].Value = model.MEMO;

            return XGWMS.DBUtility.SqlHelper.ExecuteSql(DAL_M013_STORAGE_OUTPUT_SQL.Insert_STORAGE_SQL, parameters);
        }
    }
}
